package com.study.talk.module.entity;

import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.study.talk.module.entity.vo.UserInfoVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

/**
 * <p>
 *
 * </p>
 *
 * @author thor
 * @since 2023-12-18
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("user_info")
@ApiModel(value = "UserInfo对象", description = "")
public class UserInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("用户id")
    @TableId(value = "id")
    private Integer id;

    @ApiModelProperty("用户名")
    private String username;

    @ApiModelProperty("用户昵称")
    private String nickName;

    @ApiModelProperty("用户性别")
    private Integer gender;

    @ApiModelProperty("用户邮箱")
    private String email;

    @ApiModelProperty("用户头像地址")
    private String avatar;

    @ApiModelProperty("用户生日")
    private String birth;

    @ApiModelProperty("用户住址")
    private String address;

    @ApiModelProperty("用户简介")
    private String introduce;

    @ApiModelProperty("用户主页背景图片地址")
    private String bgImg;

    @ApiModelProperty("用户点赞数")
    private Integer likeCount;

    @ApiModelProperty("用户手机号")
    private String phone;

    @ApiModelProperty("创建时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", locale = "GMT+8")
    @JSONField(format="yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    public UserInfo(UserInfoVo user) {
        this.id = user.getUserId();
        this.username = user.getUsername();
        this.email = user.getEmail();
        this.nickName = user.getNickName();
        this.phone = user.getPhone();
        this.gender = user.getGender();
        this.introduce = user.getIntroduce();
        this.likeCount = 0;
        this.avatar = user.getAvatar();
        this.birth = user.getBirth();
        this.address = user.getAddress();
        this.bgImg = user.getBgImg();
    }

    public UserInfo(Integer userId, String username, String phoneNumber) {
        this.id = userId;
        this.phone = phoneNumber;
        this.username = username;
        this.likeCount = 0;
    }
}
